package com.eureka.test;

import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @description: Demo
 * @author: cxz
 * @date: 2020/10/29 18:54
 * @version: v1.0
 */
@RestController
@RequestMapping("testOne")
public class Demo {

    public String testOne(){
        return "testTwo";
    }

    private static void testTwo(Map<Integer,String> map,TreeTest treeTest,int i){
        if (null==treeTest){
            i=1;
             treeTest = new TreeTest();
            treeTest.setValue(map.get(1));
            int s =i+1;
            testTwo(map,treeTest,s);
        }else {
            TreeTest treeTest1 = new TreeTest();
            treeTest.setTreeTestList(treeTest1);
            String s = map.get(i);
            if (StringUtils.isEmpty(s)){
                return;
            }
            treeTest1.setValue(s);
           i= i+1;
            testTwo(map,treeTest1,i);
        }

    }

    public static void main(String[] args) {
        Map<Integer,String>map=new HashMap<>();
        map.put(1,"one");
        map.put(2,"two");
        map.put(3,"three");
        map.put(4,"four");
        map.put(5,"five");
        testTwo(map,null,0);
    }
}
